package cn.com.note.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.blankj.utilcode.util.LogUtils;

import cn.com.note.R;
import cn.com.note.view.MenuButton;

/**
 * Created by sunfulin on 2019/1/5.
 */

public class EditViewActivity extends AppCompatActivity implements View.OnClickListener {
    boolean isEnable = true;
    EditText editText,editText2;
    MenuButton menuButton,menuButton1,menuButton2;
    LinearLayout ll_edit;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit);
        editText = findViewById(R.id.et_content);
        menuButton=findViewById(R.id.bt_upload_file_create);
        menuButton1=findViewById(R.id.bt_upload_file);
        menuButton2=findViewById(R.id.bt_syn_base_data);
        ll_edit=findViewById(R.id.ll_edit);
        findViewById(R.id.bt_enable).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(EditViewActivity.this, "" + isEnable, Toast.LENGTH_SHORT).show();
                isEnable = !isEnable;
                editText.setEnabled(isEnable);
            }
        });
        editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                Log.d("当前按钮 editText>|","上"+hasFocus);
            }
        });
        EditText et=new EditText(this);
        EditText et2=new EditText(this);
        ll_edit.addView(et);
        ll_edit.addView(et2);
        et.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                Log.d("当前按钮 editText>|","et "+hasFocus);
            }
        });
        et2.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                Log.d("当前按钮 editText>|","et2 "+hasFocus);
            }
        });
        LogUtils.log(Log.INFO,"内容：","EditViewActivity 页启动");
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt_upload_file_create:
                menuButton.setChecked(true);
                Toast.makeText(this, "点击了，上传文件生成", Toast.LENGTH_SHORT).show();
                break;
            case R.id.bt_upload_file:
                menuButton1.setChecked(true);
                Toast.makeText(this, "点击了，上传文件", Toast.LENGTH_SHORT).show();
                break;
            case R.id.bt_syn_base_data:
                menuButton2.setChecked(true);
                Toast.makeText(this, "点击了，同步基础数据", Toast.LENGTH_SHORT).show();
                break;

        }
    }
}
